package com.amarsoft.apot.controller;

import com.alipay.api.AlipayApiException;
import com.amarsoft.apot.entity.Order;
import com.amarsoft.apot.service.AliPayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class PayController {

    @Autowired
    private AliPayService aliPayService;
    /**
     * 支付宝支付 api
     * @return
     * @throws AlipayApiException
     */
    @PostMapping(value = "/pay/confirm")
    public String alipay() throws AlipayApiException {
        Order order = new Order();
        order.setOut_trade_no("123456");
        order.setSubject("笔记本电脑");
        order.setTotal_amount("5400");
        order.setDescription("货真价实!");
        System.out.println(order);
        return aliPayService.aliPay(order);
    }
}